﻿//cesium 三维的影响结构数据 -->
// 初始化地图

var PanShow = (function () {
    // 初始化
    function PanShow() {
        // 属性

    };

    ////
    PanShow.prototype.init = function (options) {
        this.loadpan(options);
    }
    PanShow.prototype.loadpan = function (options) {
        var that = this;
        this.panid = options.panid;
        
       
        that.count = 0;

        var data = {
            "panid": options.panid,
        };
        //
        console.info(that.controls);
        $.ajax({
            type: "POST",
            dataType: "json",
            contentType: "application/json",
            url: "pans/getpanbyid",
            data: JSON.stringify(data),
            success: function (data) {
                that.count = data[0].pancount;
                var tmpcontous = JSON.parse(data[0].content)
                console.info(tmpcontous);
                $.each(tmpcontous, function (i, val) {
                    var cchtml = '<div data=\'' + JSON.stringify({
                        "type": val.type
                    }) + '\' id="' + val.id + 'cc" class="dragresize-content"></div>';
                    var jsobj = 'var mypan=new ' + val.type + '(); mypan.init({"id":"' + val.id + 'cc' + '"});';
                    that.createcontrol({
                        "id": val.id,
                        "type": val.type,
                        "html": cchtml,
                        "jsobj": jsobj,
                        "data": val.content,
                        "left": val.postion.left,
                        "top": val.postion.top,
                        "width": val.postion.width,
                        "height": val.postion.height,
                        "zindex": val.zindex
                    });
                    //初始化执行脚本
                });
            }
        });
    }

    PanShow.prototype.createcontrol = function (options) {
        var that = this;

        //拖拽边框样式
        var style = 'left:' + options.left + ';top:' + options.top + ';width:' + options.width + ';height:' + options.height +
            ';background:transparent; text-align: center;';
        if (options.zindex) {
            style += 'z-index:' + options.zindex;
        }
        var _daragdiv = '<div id="' + options.id + 'cd" data=\'{"id":"' + options.id +
            'cd"}\' class="drsElement drsMoveHandle" style="' + style + '">' + options.html + '</div>';
        var dragdiv = $(_daragdiv);
        //内容对象
        var contentdiv = dragdiv.find("#" + options.id + "cc");


        $("#workbox").append(dragdiv);
        //初始化对象内容        
        eval(options.jsobj);
        //添加到列表对象
 
       // console.info(that.controls);
 
    }
    // 返回
    return PanShow;
})();
var panshow;
$(function () {
    var panid = getquery("panid", location.href)

    panshow = new PanShow();
    panshow.init({"panid":panid});
})
